//
//  YDTableViewController.swift
//  weibo
//
//  Created by 孙亚东 on 16/6/23.
//  Copyright © 2016年 Sunyadong. All rights reserved.
//

import UIKit

class YDTableViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //自定义tabbar
        
        //YDTabBar()
        
        let bar = YDTabBar()
        
        
//mark -----实现添加按钮的点击方法
        
        bar.closure = { ()->() in
        
            YDAddActionView.receiveVC(self)

        }
    
        //利用kvc修改tabbarController的tabbar
        setValue(bar, forKey: "tabBar")
        
        UITabBar.appearance().tintColor = UIColor.orangeColor()
        
        
        // 添加子控制器
        let homeVC = YDHomeViewController()
        addChildViewController(homeVC, imageNor: "tabbar_home" , titleTab: "主页")
    
        let messageVC = YDMessageViewController()
        addChildViewController(messageVC, imageNor: "tabbar_message_center", titleTab: "消息")
        
        let dicVC = YDDiscoveryViewController()
        addChildViewController(dicVC, imageNor:"tabbar_discover" , titleTab: "发现")
        
        let settingVC = YDSettingViewController()
        addChildViewController(settingVC, imageNor:"tabbar_profile" , titleTab: "我的")

        
    }
    
    
    //重载一个方法添加跟控制器

    func addChildViewController(childController: UIViewController, imageNor: String, titleTab: String) {
        
        childController.title = titleTab
        
        childController.tabBarItem.image = UIImage(named: imageNor)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageNor)_highlighted")
        
        let naviVC: UINavigationController = UINavigationController(rootViewController: childController)
  
        addChildViewController(naviVC)
        
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

  
}
